package com.zyylr.classroomreservationsystem.others;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zyylr.classroomreservationsystem.R;
import com.zyylr.classroomreservationsystem.bean.Information;

import java.util.List;

/**
 * Created by lw on 2017/4/14.
 */
public class ListViewUserCenterAdapter extends ArrayAdapter {
    private final int resourceId;

    public ListViewUserCenterAdapter(Context context, int listViewResourceId, List<Information> objects) {
        super(context, listViewResourceId, objects);
        resourceId = listViewResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Information information = (Information) getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId, null);
        //实例化一个对象
        ImageView informationImage = (ImageView) view.findViewById(R.id.information_image);
        ImageView information_image_you = view.findViewById(R.id.information_image_you);
        //获取该布局内的图片视图
        TextView informationName = (TextView) view.findViewById(R.id.information_name);
        //获取该布局内的文本视图
        informationImage.setImageResource(information.getImageId());
        information_image_you.setImageResource(information.getImageId_you());
        //为图片视图设置图片资源
        informationName.setText(information.getName());
        //为文本视图设置文本内容
        return view;
    }
}
